<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let  channel = new MessageChannel()

        let port1 = channel.port1;
        let port2 = channel.port2;
        // let port3 = channel.port3;  //  没有 第三个 通道

        port1.onmessage = function(e) {
            console.log("port 1 接收到数据", e.data)
        }

        port2.onmessage = function(e) {
            console.log("port 2 接收到数据", e.data)
        }

        // port3.onmessage = function(e) {  
        //     console.log("port 3 接收到数据", e.data)
        // }

        port1.postMessage("port 1 数据")
        port2.postMessage("port 2 数据")
        // port3.postMessage("port 3 数据")
    </script>
</body>
</html>